package com.ihr360.payroll.controller.salarytax;

import com.ihr360.authority.sharing.annonation.ControlMode;
import com.ihr360.authority.sharing.annonation.RestControl;
import com.ihr360.authority.sharing.privilege.AccessControlMethod;
import com.ihr360.maven.plugin.ModuleCodeStore;
import com.ihr360.maven.plugin.annotation.FunctionDefinition;
import com.ihr360.maven.plugin.annotation.ModuleDefinition;
import com.ihr360.payroll.config.SalaryTaxTableEntity;
import com.ihr360.payroll.model.dto.salary.tax.SalaryTaxTable;
import com.ihr360.payroll.service.salarytax.SalaryTaxTableService;
import com.ihr360.rest.service.SimpleRestService;
import com.ihr360.rest.webmvc.AbstractRestSimpleWithLongIdController;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author richey
 */
@RestController
@RequestMapping("/simpleSalaryTaxTables")
@ModuleDefinition(mainModuleCode = ModuleCodeStore.Module.SALARY_CODE_ADMIN, mainModuleName = ModuleCodeStore.Module.SALARY_NAME_ADMIN, hasExtendsAbstractRestController = true,
        subModuleCode = ModuleCodeStore.Module.SalaryAdmin.TAX_TABLE_CODE, subModuleName = ModuleCodeStore.Module.SalaryAdmin.TAX_TABLE_NAME, isPublic = true)
@RestControl(mode = ControlMode.ALLOW, controls = {AccessControlMethod.METHODS.search})
public class SimpleSalaryTaxTableController extends AbstractRestSimpleWithLongIdController<SalaryTaxTable> {


    @Autowired
    private SalaryTaxTableService salaryTaxTableService;


    @Override
    public SimpleRestService<SalaryTaxTable, Long> getSimpleRestService() {
        return salaryTaxTableService;
    }


    /**
     * 获取当前生效的记录
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "获取当前生效的税表")
    @GetMapping("/currentEffective")
    @FunctionDefinition(functionName = "获取当前生效的税表", functionCode = ModuleCodeStore.Function.VIEW)
    public SalaryTaxTableEntity getCurrentEffective(@RequestParam Long id) {
        return salaryTaxTableService.getCurrentEffective(id);
    }

}



